#include "AdventureCard.h"
#include <qpainter.h>

AdventureCard::AdventureCard(std::string iName, std::string iDesc, QImage *img, QWidget *parent) : 
QWidget(parent),
faceImage(img),
encounterNumber(0),
name(iName),
description(iDesc),
mFaceUp(true),
mInstruction(0)

{
	setFixedSize(148, 228);
	backImage.load("Images\\adventureCard-back.gif");
	background.load("Images\\adventureCard.gif");
	exclam.load("Images\\exclam.gif");

}

AdventureCard::AdventureCard(QWidget *parent) : 
QWidget(parent),
faceImage(0),
encounterNumber(0),
name(""),
description(""),
mFaceUp(true)
{
	setFixedSize(148, 228);
	backImage.load("Images\\adventureCard-back.gif");
	background.load("Images\\adventureCard.gif");
	exclam.load("Images\\exclam.gif");
}

AdventureCard::~AdventureCard()
{
	if( 0 != faceImage)
		delete faceImage;
	if ( 0 != mInstruction)
		delete mInstruction;
}

void AdventureCard::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
	if (mFaceUp)
	{
		painter.drawImage(0,0,background.scaledToHeight(height()));
		painter.drawText(36,30,name.c_str());
		if (0 != faceImage)
			painter.drawImage(25,40,faceImage->scaledToWidth(100));
		
		QRect r (25, 145, 100, 100);
		painter.drawText(r, getDescription().c_str());

		if(getInstruction() != 0)
			painter.drawImage(90, 100, exclam);

	}
	else
		painter.drawImage(0,0,backImage.scaledToHeight(height()));


}